#! /bin/sh /usr/share/dpatch/dpatch-run
## 01_force_kernel_failure.dpatch.dpatch by  <david@evans>
##
## All lines beginning with `## DP:' are a description of the patch.
## DP: Force build failure for SSE1/2 kernels when ATL_SSE1/2 is not defined.

@DPATCH@

diff --git a/include/contrib/camm_util.h b/include/contrib/camm_util.h
index 6b150d3..f1c2fee 100644
--- a/include/contrib/camm_util.h
+++ b/include/contrib/camm_util.h
@@ -334,7 +334,10 @@ typedef struct {
 #endif
 
 #undef mxx
-#define mxx(a_)        str(%%xmm ## a_)
+#define mxx(a_) \
+{ \
+ str(%%xmm ## a_); \
+}
 #undef prp
 #define prp(a_,b_)     "rcpp" SSESUF mxx(a_) "," mxx(b_) "\n\t"
 #undef prps
diff --git a/tune/blas/gemm/CASES/ATL_dmm6x1x72_sse2.c b/tune/blas/gemm/CASES/ATL_dmm6x1x72_sse2.c
index ebf5246..dec12d8 100644
--- a/tune/blas/gemm/CASES/ATL_dmm6x1x72_sse2.c
+++ b/tune/blas/gemm/CASES/ATL_dmm6x1x72_sse2.c
@@ -29,6 +29,9 @@
  */
 #include "atlas_asm.h"
 
+#ifndef ATL_SSE2
+   #error "This kernel requires SSE2"
+#endif
 
 #if !defined(ATL_GAS_x8632) && !defined(ATL_GAS_x8664)
    #error "This kernel requires x86 gas 32 or 64 bit x86 assembler!"
diff --git a/tune/blas/gemm/CASES/ATL_dmm8x1x120_L1pf.c b/tune/blas/gemm/CASES/ATL_dmm8x1x120_L1pf.c
index 2845e21..a39f7d2 100644
--- a/tune/blas/gemm/CASES/ATL_dmm8x1x120_L1pf.c
+++ b/tune/blas/gemm/CASES/ATL_dmm8x1x120_L1pf.c
@@ -37,6 +37,9 @@
  * to use a smaller block factor (for better application performance).
  * This kernel does not do well for complex.
  */
+#ifndef ATL_SSE2
+   #error "This kernel requires SSE2"
+#endif
 #ifndef ATL_GAS_x8664
    #error "This kernel requires x86-64 assembly!"
 #endif
diff --git a/tune/blas/gemm/CASES/ATL_dmm8x1x120_sse2.c b/tune/blas/gemm/CASES/ATL_dmm8x1x120_sse2.c
index 983de68..8223854 100644
--- a/tune/blas/gemm/CASES/ATL_dmm8x1x120_sse2.c
+++ b/tune/blas/gemm/CASES/ATL_dmm8x1x120_sse2.c
@@ -29,6 +29,9 @@
  */
 #include "atlas_asm.h"
 
+#ifndef ATL_SSE2
+   #error "This kernel requires SSE2"
+#endif
 
 /*
  * This routine designed for Core2, which seems to have relatively few
diff --git a/tune/blas/gemm/CASES/ATL_dmm_sse2_K.c b/tune/blas/gemm/CASES/ATL_dmm_sse2_K.c
index 8f59344..230363a 100644
--- a/tune/blas/gemm/CASES/ATL_dmm_sse2_K.c
+++ b/tune/blas/gemm/CASES/ATL_dmm_sse2_K.c
@@ -36,6 +36,9 @@
  * K%2==0 && K%4!=0 cases.
  */
 
+#ifndef ATL_SSE1
+	#error "This kernel requires SSE1"
+#endif
 /*****************************************************************************/
 /*                             ATL_mm_p4_d_2K.c                              */
 /*****************************************************************************/
diff --git a/tune/blas/gemm/CASES/ATL_gemm_SSE.c b/tune/blas/gemm/CASES/ATL_gemm_SSE.c
index 33c6c9a..9ebede7 100644
--- a/tune/blas/gemm/CASES/ATL_gemm_SSE.c
+++ b/tune/blas/gemm/CASES/ATL_gemm_SSE.c
@@ -1,5 +1,8 @@
 
 #include "camm_util.h"
+#ifndef ATL_SSE1
+   #error "This kernel requires SSE1!"
+#endif
 #ifndef ATL_GAS_x8632
    #error "This kernel requires gas x86-32 assembler!"
 #endif
diff --git a/tune/blas/gemm/CASES/ATL_smm10x1x120_sse.c b/tune/blas/gemm/CASES/ATL_smm10x1x120_sse.c
index a97333d..b7c723e 100644
--- a/tune/blas/gemm/CASES/ATL_smm10x1x120_sse.c
+++ b/tune/blas/gemm/CASES/ATL_smm10x1x120_sse.c
@@ -34,6 +34,9 @@
  * so we have to be very careful about alignment, and things seem to work
  * better if we keep a register block within 128 bytes
  */
+#ifndef ATL_SSE2
+   #error "This kernel requires SSE2"
+#endif
 #if !defined(MB)
    #define MB 0
 #endif
diff --git a/tune/blas/gemm/CASES/ATL_smm4x1x256_sse.c b/tune/blas/gemm/CASES/ATL_smm4x1x256_sse.c
index 6d02fb0..ea97560 100644
--- a/tune/blas/gemm/CASES/ATL_smm4x1x256_sse.c
+++ b/tune/blas/gemm/CASES/ATL_smm4x1x256_sse.c
@@ -30,6 +30,9 @@
 #include "atlas_asm.h"
 
 
+#ifndef ATL_SSE2
+   #error "This kernel requires SSE2"
+#endif
 #if !defined(MB)
    #define MB 0
 #endif
diff --git a/tune/blas/gemm/CASES/ATL_smm4x1x60_4_sse2.c b/tune/blas/gemm/CASES/ATL_smm4x1x60_4_sse2.c
index 0fca6ac..dbb6b7c 100644
--- a/tune/blas/gemm/CASES/ATL_smm4x1x60_4_sse2.c
+++ b/tune/blas/gemm/CASES/ATL_smm4x1x60_4_sse2.c
@@ -36,6 +36,9 @@
  *Purposely kept small so it is retained in cache, and easy to translate when
  *not
  */
+#ifndef ATL_SSE2
+   #error "This kernel requires SSE2"
+#endif
 
 #ifndef ATL_GAS_x8632
    #error "This kernel requires gas x86-32 assembler!"
diff --git a/tune/blas/gemm/CASES/ATL_smm6x1x120_sse.c b/tune/blas/gemm/CASES/ATL_smm6x1x120_sse.c
index 288357e..85b705a 100644
--- a/tune/blas/gemm/CASES/ATL_smm6x1x120_sse.c
+++ b/tune/blas/gemm/CASES/ATL_smm6x1x120_sse.c
@@ -29,6 +29,9 @@
  */
 #include "atlas_asm.h"
 
+#ifndef ATL_SSE2
+   #error "This kernel requires SSE2"
+#endif
 
 #ifdef ATL_GAS_x8664
    #define movl movq
diff --git a/tune/blas/gemm/CASES/ATL_smm6x1x80_sse.c b/tune/blas/gemm/CASES/ATL_smm6x1x80_sse.c
index 6e85a1c..5eaefd4 100644
--- a/tune/blas/gemm/CASES/ATL_smm6x1x80_sse.c
+++ b/tune/blas/gemm/CASES/ATL_smm6x1x80_sse.c
@@ -29,6 +29,9 @@
  */
 #include "atlas_asm.h"
 
+#ifndef ATL_SSE2
+   #error "This kernel requires SSE2"
+#endif
 
 #if !defined(ATL_GAS_x8632) && !defined(ATL_GAS_x8664)
    #error "This kernel requires x86 gas 32 or 64 bit assembler!"
diff --git a/tune/blas/gemm/CASES/ATL_smm_sse1_K.c b/tune/blas/gemm/CASES/ATL_smm_sse1_K.c
index c96c6e9..100bac5 100644
--- a/tune/blas/gemm/CASES/ATL_smm_sse1_K.c
+++ b/tune/blas/gemm/CASES/ATL_smm_sse1_K.c
@@ -33,6 +33,10 @@
  * then uses Camm Maguire's general routine for other cases of K-cleanup.
  */
 
+#ifndef ATL_SSE1
+	#error "This kernel requires SSE1"
+#endif
+
 /*****************************************************************************/
 /*                             ATL_mm_sse1_4K.c                              */
 /*****************************************************************************/
diff --git a/tune/blas/gemv/CASES/ATL_gemv_SSE.c b/tune/blas/gemv/CASES/ATL_gemv_SSE.c
index 1a5a0ea..290b3f2 100644
--- a/tune/blas/gemv/CASES/ATL_gemv_SSE.c
+++ b/tune/blas/gemv/CASES/ATL_gemv_SSE.c
@@ -34,6 +34,9 @@
 #include "atlas_misc.h"
 
 #include "camm_util.h"
+#ifndef ATL_SSE1
+   #error "This kernel requires gas x86-32 assembler!"
+#endif
 #ifndef ATL_GAS_x8632
    #error "This kernel requires gas x86-32 assembler!"
 #endif
diff --git a/tune/blas/level1/COPY/copy_x86.c b/tune/blas/level1/COPY/copy_x86.c
index 208e1d4..d3efb21 100644
--- a/tune/blas/level1/COPY/copy_x86.c
+++ b/tune/blas/level1/COPY/copy_x86.c
@@ -1,5 +1,9 @@
 #include "atlas_asm.h"
 
+#ifndef ATL_SSE1
+	#error "This kernel requires SSE1"
+#endif
+
 #ifdef ATL_GAS_x8632
    #define movQ movl
    #define addq addl
diff --git a/tune/blas/level1/IAMAX/iamax8_x86.c b/tune/blas/level1/IAMAX/iamax8_x86.c
index 23d2449..6fed96e 100644
--- a/tune/blas/level1/IAMAX/iamax8_x86.c
+++ b/tune/blas/level1/IAMAX/iamax8_x86.c
@@ -1,6 +1,10 @@
 
 #include "atlas_asm.h"
 
+#ifndef ATL_SSE1
+	#error "This kernel requires SSE1"
+#endif
+
 #ifdef SREAL
 
 #ifdef ATL_GAS_x8632
diff --git a/tune/blas/level1/IAMAX/iamax_sse.c b/tune/blas/level1/IAMAX/iamax_sse.c
index dc9f385..bbbaa72 100644
--- a/tune/blas/level1/IAMAX/iamax_sse.c
+++ b/tune/blas/level1/IAMAX/iamax_sse.c
@@ -1,5 +1,9 @@
 #include "atlas_asm.h"
 
+#ifndef ATL_SSE1
+	#error "This kernel requires SSE1"
+#endif
+
 #ifdef SREAL
 
 #ifdef ATL_GAS_x8632
diff --git a/tune/blas/level1/SET/set_x86.c b/tune/blas/level1/SET/set_x86.c
index 6c25846..c5d4832 100644
--- a/tune/blas/level1/SET/set_x86.c
+++ b/tune/blas/level1/SET/set_x86.c
@@ -1,5 +1,9 @@
 #include "atlas_asm.h"
 
+#ifndef ATL_SSE1
+	#error "This kernel requires SSE1."
+#endif
+
 #ifdef SREAL
 
 #ifdef ATL_GAS_x8632
